
<extend name="Error:base" />
<block name="title"><title>确认订单</title></block>
		<block name="style2">
			<link href="__PUBLIC__/Home/css/base.css" rel="stylesheet" type="text/css">	
			<style>
				form a{text-decoration:underline;}
			</style>
		</block>		
		<block name="style">
			<link href="__PUBLIC__/Home/css/home_cart.css" rel="stylesheet" type="text/css"><link href="__PUBLIC__/Home/css/perfect-scrollbar.min.css" rel="stylesheet" type="text/css">			
		</block>
		<block name="script2">

<script>
	var COOKIE_PRE = 'F8DD_';
	var _CHARSET = 'utf-8';
	var SITEURL = window.location.host;
	var MEMBER_SITE_URL =  window.location.host;
	var RESOURCE_SITE_URL =  window.location.host;
	var RESOURCE_SITE_URL =  window.location.host;
	var SHOP_TEMPLATES_URL =  window.location.host;
	var PRICE_FORMAT = '&yen;%s';
	Number.prototype.toFixed = function(d)
	{
		var s=this+"";if(!d)d=0;
		if(s.indexOf(".")==-1)s+=".";s+=new Array(d+1).join("0");
		if (new RegExp("^(-|\\+)?(\\d+(\\.\\d{0,"+ (d+1) +"})?)\\d*$").test(s))
		{
			var s="0"+ RegExp.$2, pm=RegExp.$1, a=RegExp.$3.length, b=true;
			if (a==d+2){a=s.match(/\d/g); if (parseInt(a[a.length-1])>4)
			{
				for(var i=a.length-2; i>=0; i--) {a[i] = parseInt(a[i])+1;
				if(a[i]==10){a[i]=0; b=i!=1;} else break;}
			}
			s=a.join("").replace(new RegExp("(\\d+)(\\d{"+d+"})\\d$"),"$1.$2");
		}if(b)s=s.substr(1);return (pm+s).replace(/\.$/, "");} return this+"";
	};
</script>
			<script src="__PUBLIC__/Home/js/jquery.validation.min.js"></script>
			<script src="__PUBLIC__/Home/js/jquery.poshytip.min.js"></script>
			<script type="text/javascript" src="__PUBLIC__/Home/js/perfect-scrollbar.min.js"></script>
			<script type="text/javascript" src="__PUBLIC__/Home/js/jquery.mousewheel.js"></script>
			<script type="text/javascript" src="__PUBLIC__/Home/js/dialog.js" id="dialog_js" charset="utf-8"></script><link href="__PUBLIC__/Home/css/dialog.css" rel="stylesheet" type="text/css">
			<script src="__PUBLIC__/Home/js/goods_cart.js"></script>
		</block>
<block name="body">
<header class="ncc-head-layout">
    <div class="site-logo"><a href="/">
				<volist name="service" id="vo">
				<eq name="vo.name" value="net_logo" >
					<if condition="$vo.value neq ''">
					<img src="{$vo.value}" class="pngFix">
					<else/>
						<volist name="service" id="vo">
						<eq name="vo.name" value="net_logo" >
							<if condition="$vo.value neq ''">
							<img src="{$vo.value}" class="pngFix">
							<else/>
							<img src="__PUBLIC__/Home/images/logo.png" class="pngFix">
							</if>
						</eq>
						</volist>
					</if>
				</eq>
				</volist>	
	</a></div>
        <ul class="ncc-flow">
      <li class=""><i class="step1"></i>
        <p>我的购物车</p>
        <sub></sub>
        <div class="hr"></div>
      </li>
      <li class="current"><i class="step2"></i>
        <p>确认订单</p>
        <sub></sub>
        <div class="hr"></div>
      </li>
      <li class=""><i class="step3"></i>
        <p>支付提交</p>
        <sub></sub>
        <div class="hr"></div>
      </li>
      <li class=""><i class="step4"></i>
        <p>订单完成</p>
        <sub></sub>
        <div class="hr"></div>
      </li>
    </ul>
</header>
	  	  
<div class="ncc-wrapper">

<script type="text/javascript">
</script> 
<!-- S fcode -->
<!-- E fcode -->

<div class="ncc-main">
  <div class="ncc-title">
    <h3>确认订单</h3>
    <h5>请仔细核对填写收货、发票等信息，以确保物流快递及时准确投递。</h5>
  </div>
    
<div class="ncc-receipt-info current_box">
  <div class="ncc-receipt-info-title">
    <h3>收货人信息</h3>
	<!--默认的收货地址，否则为不选-->	
    <a href="javascript:void(0)" nc_type="buy_edit" id="edit_reciver">[修改]</a></div>

<!--最后一个为新增的收货地址-->	
  <div id="addr_list" class="ncc-candidate-items">  

 </div>
</div>

<script>
$(function(){ 
	var STATES = '{$addss_state}' ;
	var url= "{:U('shop/buy_address')}";
	//加载收货地址列表
	$('#edit_reciver').on('click',function(){
		$(this).hide();
		$(this).parent().parent().addClass('current_box');
		var html = '<ul><foreach name="address" item="vo"><li class="receive_add address_item ncc-selected-item"><input address="{$vo.province} {$vo.city} {$vo.area} {$vo.address}" true_name="{$vo.realname}" id="addr_{$vo.id}" nc_type="addr" type="radio" class="radio" name="addr" value="{$vo.id}" phone="{$vo.mob_phone}"><label for="addr_{$vo.id}"><span class="true-name">{$vo.realname}</span><span class="address">{$vo.province} {$vo.city} {$vo.area} {$vo.address}</span><span class="phone"><i class="icon-mobile-phone"></i>{$vo.mob_phone}</span></label><a href="javascript:void(0);" onclick="delAddr({$vo.id});" class="del">[ 删除 ]</a> </li></foreach><li class="receive_add addr_item"><input value="0" nc_type="addr" id="add_addr" type="radio" name="addr"><label for="add_addr">使用新地址</label>&nbsp;</li><div id="add_addr_box"></div></ul><div class="hr16"> <a id="hide_addr_list" class="ncbtn ncbtn-grapefruit" href="javascript:void(0);">保存收货人信息</a></div>';
		$('#addr_list').html(html);
	});
	
	$('input[name="addr"]').live('click',function(){
			var check = $(this).attr("checked");
			var url2 = "{:U('shop/buy_address2')}";
			var vals = $(this).val();
			if(check && vals==0){
				$('#hide_addr_list_2').attr('id','hide_addr_list');
				$('#add_addr_box').load(url2);
			} else {
				$('#add_addr_box').html('');
				$('#hide_addr_list').attr('id','hide_addr_list_2');
			}
	});	
		
	$('#hide_addr_list_2').live('click', function() {
		var check = $('input[name="addr"]:checked');
		var id = check.val();
		var address = check.attr('address');
		var phone = check.attr('phone');
		var true_name = check.attr('true_name');

		//收货地址
		$("#address_id").val(id);
		var html = '<li id="address_join" nctype="'+id+'"><span class="true-name">'+true_name+'</span><span class="address">'+address+'</span><span class="phone"><i class="icon-mobile-phone"></i>'+phone+'</span></li>';
		$('#edit_reciver').parent().parent().removeClass('current_box');
		$('#edit_reciver').show();
		$("div#addr_list").html(html);
		
	});
	 
	 if(!STATES){
		//收货地址		
		$("div#addr_list").load(url); 
	 } else {
		$('#edit_reciver').parent().parent().removeClass('current_box');
		var html = '<ul> <foreach name="address" item="vo"><if condition="$vo.is_default eq '1'"><li id="address_join" nctype="{$vo.id}"><span class="true-name" {$type=1}>{$vo.realname}</span><span class="address">{$vo.province} {$vo.city} {$vo.area} {$vo.address}</span><span class="phone"><i class="icon-mobile-phone"></i>{$vo.mob_phone}</span></li></if></foreach><if condition="$type NEQ 1"><li id="address_join" nctype="{$address.0.id}"><span class="true-name">{$address.0.realname}</span><span class="address">{$address.0.province} {$address.0.city} {$address.0.area} {$address.0.address}</span><span class="phone"><i class="icon-mobile-phone"></i>{$address.0.mob_phone}</span></li></if> </ul>' ;
		$("div#addr_list").html(html);
	 }
 }); 
 
</script> 
    
<div class="ncc-receipt-info" id="paymentCon">
  <div class="ncc-receipt-info-title">
    <h3>支付方式</h3>
       <!--  <a href="javascript:void(0)" nc_type="buy_edit" id="edit_payment_0000">[修改]</a> --><font color="#B0B0B0">如需修改，请先保存收货人信息 </font>
   </div>
  <div class="ncc-candidate-items">
    <ul>
      <li>{$payment_name}</li>
    </ul>
  </div>
  <div id="payment_list_00000" class="ncc-candidate-items" style="display:none;">
    <ul>
      <li>
        <input type="radio" value="online" name="payment_type" id="payment_type_online">
        <label for="payment_type_online">在线支付</label>
      </li>
      <li>
        <input type="radio" value="points" name="payment_type" id="payment_type_points">
        <label for="payment_type_points">消费积分支付</label>
      </li>
       <li>
        <input type="radio" value="consume" name="payment_type" id="payment_type_consume">
        <label for="payment_type_consume">消费账户支付</label>
      </li>
       <li>
        <input type="radio" value="bonus" name="payment_type" id="payment_type_bonus">
        <label for="payment_type_bonus">动态账户支付</label>
      </li>
       <li>
        <input type="radio" value="points_consume" name="payment_type" id="payment_type_points_consume">
        <label for="payment_type_points_consume">消费积分支付+消费账户支付</label>
      </li>
    </ul>
    <div class="hr16"> <a href="javascript:void(0);" class="ncbtn ncbtn-grapefruit" id="hide_payment_list">保存支付方式</a></div>
  </div>
  
</div>

<script>
$(function(){ 
	$('#edit_payment').on('click',function(){
		$(this).hide();
		$(this).parent().parent().addClass('current_box');
		$('#payment_list').show();
		var next = $(this).parent().next().html('');
	});
	
	$('#hide_payment_list').on('click',function(){
		var check = $('input[name="payment_type"]:checked');
		var name = check.next().html();
		var vals = check.val();
		var html = '<ul><li>'+name+'</li></ul>';
		//alert(vals);
		if(check){
			$("#pay_name").val(vals);
			$('#edit_payment').parent().parent().removeClass('current_box');
			$('#payment_list').hide();
			$('#edit_payment').show();
			$('#edit_payment').parent().next().html(html);
		}
		
	});

});
</script>

<!-- 在线支付和货到付款组合时，显示弹出确认层内容 -->
<div id="confirm_offpay_goods_list" style="display: none;">
  <dl class="ncc-offpay-list" data-hideshow="offline">
    <dt>以下商品支持<strong>货到付款</strong></dt>
    <dd>
      <ul data-cod-type="offline">
                <li data-cod-store="1"><span title="劳力士Rolex 宇宙计型迪通拿 自动机械皮带男表 正品116519 CR.TB"><img src=""></span></li>
              </ul>
      <label>
        <input type="radio" value="" checked="checked">
        货到付款
      </label>
    </dd>
  </dl>
  <dl class="ncc-offpay-list" data-hideshow="online">
    <dt>以下商品支持<strong>在线支付</strong></dt>
    <dd>
      <ul data-cod-type="online">
              </ul>
      <label>
        <input type="radio" value="" checked="checked">
        在线支付
      </label>
    </dd>
  </dl>

  <div class="tc mt10 mb10"><a href="javascript:void(0);" class="ncbtn ncbtn-bittersweet" id="close_confirm_button">确认支付方式</a></div>
</div>

<!-- <div class="ncc-receipt-info"><div class="ncc-receipt-info-title">
  <h3>发票信息</h3>
  <a href="javascript:void(0)" nc_type="buy_edit" id="edit_invoice" style="display: none;">[修改]</a><font color="#B0B0B0">如需修改，请先保存收货人信息 </font></div>
  <div id="invoice_list" class="ncc-candidate-items">
    <ul>
      <li>不需要发票</li>
    </ul>
  </div>
</div> -->
<script type="text/javascript">

</script>
<form method="post" id="order_form" name="order_form" action="/shop/buy_step2.html">           
<div class="ncc-receipt-info">
  <div class="ncc-receipt-info-title">
    <h3>商品清单</h3>
  </div>
  <table class="ncc-table-style">
    <thead>
      <tr>
        <th class="w50"></th>
        <th></th>
        <th>商品</th>
        <th class="w150">单价(元)</th>
        <th class="w100">数量</th>
        <th class="w150">小计(元)</th>
      </tr>
    </thead>
	<foreach name="cart_list" item="vo">
    <tbody>
	
      <tr>
        <th colspan="20"> <!-- S 店铺名称 -->          
          <div class="ncc-store-name">店铺：<a href="/shop/show_store.html?stid={$vo.store_id}">{$vo.store_name}</a> <span member_id="1"><a class="chat chat_offline" title="在线联系" href="JavaScript:chat(1);">离线</a></span></div>
        </th>
      </tr>
	  <foreach name="vo.son_c" item="svo">
      <tr id="cart_item_{$svo.cart_id}" class="shop-list ">
        <td class="td-border-left ">          
			<input type="hidden" value="{$svo.cart_id}|{$vo.store_id}" store_id="{$svo.cart_id}" name="cart_id[]">
			<input type="hidden" value="{$svo.goods_id}|{$svo.goods_num}" name="goods_id[]">
         </td>
         <td class="w100">
			<a href="/shop/goods.html?gid={$svo.goods_id}" target="_blank" class="ncc-goods-thumb"><img src="{$svo.goods_image}" alt="{$svo.goods_name}"></a>
		 </td>
         <td class="tl"><dl class="ncc-goods-info">
            <dt>
                <a href="/shop/goods.html?gid={$svo.goods_id}" target="_blank">{$svo.goods_name}  <font style="color:red;">{$svo.color} {$svo.spec}</font> </a>
			</dt>
            <dd class="goods-spec"></dd>
          </dl>
		</td>
        <td><!-- S 商品单价 -->
          <em class="goods-price">
			{$svo.m_html}
		  
		  </em><!-- E 商品单价 --> 
		</td>
        <td>{$svo.goods_num}</td>
        <td class="td-border-right">         
			<em cart_id="{$svo.cart_id}" goods_id="{$svo.goods_id}" nc_type="eachGoodsTotal{$vo.store_id}" tpl_id="{$svo.cart_id}" class="goods-subtotal">
<if condition="$svo.amount gt 0">￥ {$svo.amount} <if condition="$svo.amount_points gt 0"> + </if></if> <if condition="$svo.amount_points gt 0"> {$svo.amount_points}  积分</if>	<if condition="$svo.amount_coin gt 0"> {$svo.amount_coin}  币</if>		
			</em> 
			<span id="no_send_tpl_0" style="color: #F00;display:none">无货</span>
        </td>
      </tr>
	</foreach>
	
     <tr>
        <td colspan="20"><div class="ncc-msg">买家留言：
            <textarea name="pay_message[{$vo.store_id}]" class="ncc-msg-textarea" placeholder="选填：对本次交易的说明（建议填写已经和商家达成一致的说明）" title="选填：对本次交易的说明（建议填写已经和商家达成一致的说明）" maxlength="150"></textarea>
			<input type="hidden" value="{$vo.store_id}" name="store_id[]">
          </div>
          <div class="ncc-store-account">
            <dl>
              <dt>商品金额：</dt>
              <dd class="rule"></dd>
              <dd class="sum"><em id="eachStoreGoodsTotal_{$vo.store_id}">{$total[$vo[store_id]]}</em></dd>
            </dl>
             <dl>
              <dt>积分价：</dt>
              <dd class="rule"></dd>
              <dd class="sum"><em id="eachStoreGoodsTotal_{$vo.store_id}">{$amount_points[$vo[store_id]]}</em></dd>
            </dl>
			<if condition="$amount_coin[$vo[store_id]] gt 0">
			<dl>
              <dt>增值币价：</dt>
              <dd class="rule"></dd>
              <dd class="sum"><em id="eachStoreGoodsCoin_{$vo.store_id}">{$amount_coin[$vo[store_id]]}&nbsp;币</em></dd>
            </dl>			
			</if>
            <!-- S voucher list -->
            <dl>
              <dt>物流运费：</dt>
              <dd class="rule">
                              </dd>
              <dd class="sum"><em nc_type="eachStoreFreight" id="eachStoreFreight_{$vo.store_id}">
			  {$goods_freight[$vo[store_id]]} 

			  </em></dd>
            </dl>
            <dl class="total">
              <dt>本店合计：</dt>
              <dd class="rule"></dd>
              <dd class="sum"><em store_id="{$vo.store_id}" nc_type="">

<if condition="$total[$vo[store_id]] gt 0">￥ {$total[$vo[store_id]]} 

<if condition="$amount_points[$vo[store_id]] gt 0"> + </if>

</if> 

<if condition="$amount_points[$vo[store_id]] gt 0">
 
{$amount_points[$vo[store_id]]}  积分 
</if>

<if condition="$amount_coin[$vo[store_id]] gt 0">
	
	<if condition="$total[$vo[store_id]] gt 0"> + <else/>
	<if condition="$amount_points[$vo[store_id]] gt 0"> + </if>		
	</if>	
	{$amount_coin[$vo[store_id]]} 币
</if>
	</em>
			  </dd>
            </dl>
          </div></td>
      </tr>
    </tbody>

	</foreach>  
	
    <tfoot>
      <!-- S rpt list -->
      
      <!-- E rpt list -->
      <tr>
        <td colspan="20">          
			<a href="{:U('shop/shop_cart')}?type=shop_cart" class="ncc-prev-btn"><i class="icon-angle-left"></i>返回购物车</a>
			 
			 <div class="ncc-all-account">订单总金额：<em id="orderTotal">
			 <if condition="$alltotal gt 0">￥ {$alltotal} 
				 <if condition="$allpoints gt 0"> +  
				 </if>			 
			 </if> 

			 <if condition="$allpoints gt 0"> {$allpoints}  积分
				<if condition="$allcoins gt 0"> + </if>
			 </if>
			 
			 <if condition="$allcoins gt 0"> 				 
				<if condition="$alltotal gt 0"> +  
				 </if>	
				{$allcoins}  币
			 </if>
			 </em></div>
			  <a href="javascript:void(0)" id="submitOrder" class="ncc-next-submit">提交订单</a>
		  </td>
      </tr>
    </tfoot>
  </table>
</div>

  <script type="text/javascript">
//是否允许表单提交
var SUBMIT_FORM = true;
//记录无货的店铺ID数组
var no_send_tpl_ids = [];
//当前可用的红包
var rpt_list_json = $.parseJSON('[]');
//记录选中的门店自提ID，查询库存需要
var chain_id = '';
var chain_store_id = '';
//哪 些商品ID不可以门店自提
var no_chain_goods_ids = [];

function submitNext(){
	if (!SUBMIT_FORM) return;

	if ($('input[name="cart_id[]"]').size() == 0) {
		showDialog('所购商品无效', 'error','','','','','','','','',2);
		return;
	}
    if ($('#address_id').val() == ''){
		showDialog('请先设置收货地址', 'error','','','','','','','','',2);
		return;
	}

	SUBMIT_FORM = false;
 	$('#order_form').submit();
}

 calcOrder();
//计算总运费和每个店铺小计
function calcOrder() {
   var allTotal = 0;
    $('em[nc_type="eachStoreTotal"]').each(function(){
        var store_id = $(this).attr('store_id');
        var eachTotal = 0;
        $('em[nc_type="eachGoodsTotal'+store_id+'"]').each(function(){
		
        	if (no_send_tpl_ids[$(this).attr('tpl_id')]) {
     		    $(this).next().show();
				
     		    $('#cart_item_'+$(this).attr('cart_id')).addClass('item_disabled');
     		} else {

         		if (no_chain_goods_ids[$(this).attr('goods_id')]){
         		    $(this).next().show();
         		    $('#cart_item_'+$(this).attr('cart_id')).addClass('item_disabled');
             	} else {
         		    $(this).next().hide();
           		    $('#cart_item_'+$(this).attr('cart_id')).removeClass('item_disabled');
                }
     		}
        });

        if ($('#eachStoreGoodsTotal_'+store_id).length > 0) {
        	eachTotal += parseFloat($('#eachStoreGoodsTotal_'+store_id).html().replace(/,/g,''));
	    }
        if ($('#eachStoreManSong_'+store_id).length > 0) {
        	eachTotal += parseFloat($('#eachStoreManSong_'+store_id).html().replace(/,/g,''));
	    }
        if ($('#eachStoreVoucher_'+store_id).length > 0) {
        	eachTotal += parseFloat($('#eachStoreVoucher_'+store_id).html().replace(/,/g,''));
        }
        if ($('#eachStoreFreight_'+store_id).length > 0) {
        	eachTotal += parseFloat($('#eachStoreFreight_'+store_id).html().replace(/,/g,''));
	    }
        allTotal += eachTotal;
		//alert(eachTotal);
        $(this).html(eachTotal.toFixed(2));
    });
    
    if ($('#orderRpt').length > 0) {
    	iniRpt(allTotal.toFixed(2));
    	$('#orderRpt').html('-0.00');
    }
    //$('#orderTotal').html(allTotal.toFixed(2));
    $('#submitOrder').on('click',function(){submitNext()}).addClass('ok');
}	
  </script> 
  
<div class="ncc-wrapper">
    
    <input value="buy" type="hidden" name="act">
    <input value="buy_step2" type="hidden" name="op">
    <!-- 来源于购物车标志 -->
    <input value="" type="hidden" name="ifcart">

    <!-- 支付方式 -->
    <input value="online" name="pay_name" id="pay_name" type="hidden">

    <!-- 是否保存增值税发票判断标志 -->
    <input value="" name="vat_hash" type="hidden">

    <!-- 收货地址ID -->
	<foreach name="address" item="vo">
	<if condition="$vo.is_default eq '1'">
		<input value="{$vo.id}" name="address_id" id="address_id" type="hidden" {$type=1}>
	</if>
	</foreach>
	<if condition="$type NEQ 1">
		<input value="{$address.0.id}" name="address_id" id="address_id" type="hidden">
	</if> 
    

    <!-- 城市ID(运费) -->
    <input value="" name="buy_city_id" id="buy_city_id" type="hidden">

</div>
</form>
  <script type="text/javascript">
	//获取购物车
	var cart_id = new Array();
	cart_id = [];	
	
	$('em[nc_type="eachStoreTotal"]').each(function(){
		var store_id = $(this).attr('store_id');	
		$('em[nc_type="eachGoodsTotal'+store_id+'"]').each(function(){
			 cart_id.push($(this).attr('cart_id')) ;			
		});
		$('input[name="ifcart"]').val(cart_id);
			//alert(cart_id);
	});
  </script> 

</div>
</br>
</br>
</br>
</br>
</block>	


